<template>
	<view class="ys-page">
		<view class="list">
			<view class="item" v-for="(item,index) in list" :key="index">
				<view class="imgbox">
					<image :src="item.imageUrl || '/static/0.png'" mode="aspectFill"></image>
				</view>
				<view class="infobox">
					<view class="name">
						{{item.name}}
						<text>{{item.nation}}</text>
						<text v-if="item.gender == 0">男</text>
						<text v-else-if="item.gender == 1">女</text>
					</view>
					<view class="phone">
						{{item.mobile}}
					</view>
					<view class="phone">
						{{item.idNum}}
					</view>
				</view>
			</view>
			<view class="no-list" v-if="list.length == 0">
				- 暂无数据 -
			</view>
		</view>
	</view>
</template>

<script>
	import {
		tenantlist
	} from "@/api/system.js"
	export default {
		data() {
			return {
				houseId: '',
				roomId: '',
				pageNum: 1,
				last_page: 1,
				list: []
			}
		},
		onLoad(e) {
			if (e.houseId) this.houseId = e.houseId
			if (e.roomId) this.roomId = e.roomId
			this.tenantlist()
		},
		onReachBottom() {
			if (this.pageNum < this.last_page) {
				this.pageNum++
				this.tenantlist()
			}
		},
		methods: {
			tenantlist() {
				tenantlist({
					houseId: this.houseId,
					roomId: this.roomId,
					pageNum: this.pageNum,
					pageSize: 15
				}).then(res => {
					if (res.code == 200) {
						this.list = this.list.concat(res.data.records)
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	.list {
		padding: 10px;
		box-sizing: border-box;

		.item {
			padding: 10px;
			box-sizing: border-box;
			border-radius: 8px;
			display: flex;
			align-items: center;
			background: #fff;

			.imgbox {
				width: 80px;
				height: 80px;

				image {
					width: 100%;
					height: 100%;
				}
			}

			.infobox {
				width: calc(100% - 80px);
				padding-left: 10px;
				box-sizing: border-box;

				.name {
					font-weight: bold;

					text {
						font-weight: normal;
						margin-left: 8px;
						font-size: 12px;
					}
				}

				.phone {
					margin-top: 8px;
					font-size: 14px;
					color: #777;
				}
			}
		}
	}
</style>